﻿
// !!! 请根据你的实际数据库信息修改连接字符串 !!!
using ConsoleApp2;

string myConnectionString = "Data Source=<your ip>;port=3306;Initial Catalog=<your dbname>;user id=<your account>;password=<your password>;charset=utf8mb4;Allow User Variables=True";

// 要生成实体类的表名
string tableNameToGenerate = "t_user"; // 例如: "users", "products"

// 实体类文件的输出目录
string outputDir = @"D:\test1"; // 例如: @"C:\MyProject\Models"

// 实体类所属的命名空间（可选）
string entityNamespace = "MyProject.Models"; // 例如: "MyApp.Entities"

try
{
    EntityGenerator generator = new EntityGenerator(myConnectionString);
    generator.GenerateEntityClass(tableNameToGenerate, outputDir, entityNamespace);

    // 可以依次生成多个表的实体类
    // generator.GenerateEntityClass("another_table", outputDir, entityNamespace);

    Console.WriteLine("\nEntity generation process completed. Press any key to exit.");
    Console.ReadKey();
}
catch (Exception ex)
{
    Console.WriteLine($"An error occurred: {ex.Message}");
    Console.WriteLine(ex.StackTrace);
    Console.ReadKey();
}
